/*****************************************************************************
 * Copyright (C) Stacy Curl. All rights reserved.                            *
 * ------------------------------------------------------------------------- *
 * The software in this package is published under the terms of the BSD      *
 * style license a copy of which has been included with this distribution in *
 * the LICENSE.txt file.                                                     *
 *****************************************************************************/
package picounit.features.ruby_string.delayed;

import moved.org.objectweb.asm.AnnotationVisitor;

import java.util.LinkedList;
import java.util.List;

public class DefaultAnnotationInstructions implements AnnotationInstructions {
	private final List<AnnotationInstruction> instructions =
		new LinkedList<AnnotationInstruction>();

	public AnnotationInstructions add(AnnotationInstruction instruction) {
		instructions.add(instruction);

		return this;
	}

	///////////////////////////////////////////////////////////////////////////////////////////////
	// AnnotationInstructions Methods
	///////////////////////////////////////////////////////////////////////////////////////////////

	public void inform() {
		for (AnnotationInstruction annotationInstruction : instructions) {
			inform(annotationInstruction);
		}
	}

	///////////////////////////////////////////////////////////////////////////////////////////////
	// AnnotationInstruction Methods
	///////////////////////////////////////////////////////////////////////////////////////////////

	public void accept(AnnotationVisitor annotationVisitor) {
		for (AnnotationInstruction instruction : instructions) {
			instruction.accept(annotationVisitor);
		}
	}

	public void inform(AnnotationInstruction annotationInstruction) {
		for (AnnotationInstruction instruction : instructions) {
			instruction.inform(annotationInstruction);
		}
	}
	
	///////////////////////////////////////////////////////////////////////////////////////////////
	// Object Methods
	///////////////////////////////////////////////////////////////////////////////////////////////

	@Override
	public boolean equals(Object object) {
		if (object == null || !(object.getClass().equals(getClass()))) {
			return false;
		}

		DefaultAnnotationInstructions other = (DefaultAnnotationInstructions) object;

		return instructions.equals(other.instructions);
	}
}
